package org.example;

public class 第三章_对象和类 {
    public static void main(String[] args) {
        //创建employee1,使用构造函数
        Employee employee1 = new Employee("RUNOOB1",20);
        //创建employee2,使用set
        Employee employee2 = new Employee();
        employee2.setName("RUNOOB2");
        employee2.setAge(30);

        //打印输出
        System.out.println(employee1);
        System.out.println(employee2);
    }

    //创建一个类
    static class Employee {
        public String name;//名称
        public Integer age;//年龄

        //构造函数
        public Employee(String name,Integer age){
            this.name=name;
            this.age=age;
        }

        public Employee(){}

        public Integer getAge() {
            return age;
        }

        public String getName() {
            return name;
        }

        public void setAge(Integer age) {
            this.age = age;
        }

        public void setName(String name) {
            this.name = name;
        }

        @Override
        public String toString(){
            return "姓名: "+ this.name+
                    " 年龄:"+this.age;
        }
    }

}
